package com.mabs.ground.server.rest;

import java.util.ArrayList;
import java.util.List;

public class DataResponse<T> {
	 private List<T> data;

	    private int startRow;

	    private int endRow;

	    private int totalRows;

	    private DataResponse() {
	    }

	    public DataResponse(List<T> data) {
	        this.data = data;
	        this.startRow = 0;
	        this.endRow = data.size() - 1;
	        this.totalRows = data.size();
	    }

	    public DataResponse(List<T> data, int startRow, int endRow, int totalRows) {
	        this.data = data;
	        this.startRow = startRow;
	        this.endRow = endRow;
	        this.totalRows = totalRows;
	    }

	    public List<T> getData() {
	        if (data == null) {
	            data = new ArrayList<T>();
	        }
	        return data;
	    }

	    public int getStartRow() {
	        return startRow;
	    }

	    public int getEndRow() {
	        return endRow;
	    }

	    public int getTotalRows() {
	        return totalRows;
	    }

	    public static <E> DataResponse<E> createEmptyResponse() {
	        return new DataResponse<E>();
	    }
}
